package com.example.chinamobileai.tool;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.chinamobileai.domain.PhonePlan;
import com.example.chinamobileai.domain.PhonePlanQuery;
import com.example.chinamobileai.service.IPhonePlanService;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class MyTool {

    @Autowired
    private IPhonePlanService phonePlanService;
    @Tool(description = "根据查询条件获取套餐列表")
    public List<PhonePlan> getPhonePlanList(@ToolParam(required = false,description = "查询条件") PhonePlanQuery query) {

        if(query == null){
            return phonePlanService.list();
        }

        QueryWrapper<PhonePlan> queryWrapper = new QueryWrapper<>();
        queryWrapper.le("monthly_fee", query.getMonthlyFee());
        queryWrapper.eq("data_flow", query.getDataFlow());
        queryWrapper.eq("call_duration", query.getCallDuration());
        queryWrapper.eq("additional_service", query.getAdditionalService());
        return phonePlanService.list(queryWrapper);
    }

    @Tool(description = "查询所有套餐")
    public List<PhonePlan> getAllSchool() {
        return phonePlanService.list();
    }


}
